import { PageRequestData, ResponseTableData, TableData } from "@@/apis/common"
import { BSDataTypeEnum, RecordTypeEnum } from "@@/constants/other-keys"

// 数据结构-类参数
export interface BasicClassField {
  id?: string
  // 标识
  code?: string
  // 辅助标识
  name?: string
  // class类 1基本类型 2数组类型
  recordType?: RecordTypeEnum
  // 参数连接符
  separator?: string
  // 数组参数连接符
  daSeparator?: string
  // class类 enum枚举 base原始类型
  type?: BSDataTypeEnum
  // 类型ID
  typeId?: string
  // 类型标识
  typeCode?: string
  // 数据结构id
  baseDataId?: string
  // 序号
  sort: number
  // 其他参数
  [propName: string]: any
}
// 数据结构-枚举参数
export interface BasicEnumField {
  id?: string
  // 枚举值
  value?: string
  // 注释
  comment?: string
  // 数据结构id
  baseDataId?: string
  // 编码
  code?: string
  // 其他参数
  [propName: string]: any
}
// 数据结构-基本参数
export interface BasicDataInfo {
  // 主键
  id: string | undefined
  // 编码
  code: string
  // 名称
  name: string
  // 描述
  description: string
  // class类 enum枚举
  type: BSDataTypeEnum
  // 参数连接符
  separator: string
  // 标签名称
  tag: string
  // 父类id
  parentId: string
}
export interface BasicClassValueField extends BasicClassField {
  staticFlag?: number
  functionId?: string
  value: string
  children?: BasicClassValueField[],
  _XID?: string
  establish?: boolean,
  uuid?: string
}

export interface BasicEnumField {
  id?: string
  value?: string
  code?: string
  common?: string
}

export interface BasicViewInfo {
  basicData: BasicDataInfo
  fields: BasicClassField[]
  enums: BasicEnumField[]
}
export interface TableRequestData {
  type: BSDataTypeEnum
  code: string | undefined
}

export interface SaveRequestData {
  basicData: BasicDataInfo
  insertFields?: BasicClassField[]
  removeFields?: BasicClassField[]
  updateFields?: BasicClassField[]
  insertEnums?: BasicEnumField[]
  removeEnums?: BasicEnumField[]
  updateEnums?: BasicEnumField[]
}

export interface PageTableRequestData extends TableRequestData, PageRequestData {
  name?: string
  description?: string
  country?: string
  type: BSDataTypeEnum
  searchKey?: string
  create_time?: string
  end_time?: string
}
export interface BSTableData extends BasicDataInfo, Omit<TableData, 'create_user' | 'create_time'> {
  id: string
  create_time: string
  create_user: {
    user_id: string
    user_name: string
    user_position: string
  }
  isSelected?: boolean
}
// 参数值返回信息
export type BSViewResData = ApiResponseData<BasicViewInfo>
export type BSFieldResData = ApiResponseData<BasicClassValueField[]>
export type BSEnumResData = ApiResponseData<BasicEnumField[]>
export type BSTableResData = ApiResponseData<ResponseTableData<BSTableData>>
